﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using BrokerBase.Lib.Client;
using Broker.Service.EntityModel;

namespace Broker.Service.Model
{
    public class ToolUtil
    {
        public static bool VerifyLicense(RegistrantInfo registrantInfo, TerminalInfo terminalInfo, broker30Entities entity)
        {

            Sale_ActiveCodeReg codeReg = (from reg in entity.Sale_ActiveCodeReg
                                      join code in entity.Sale_ActiveCode on reg.ActiveCodeId equals code.Id
                                      join client in entity.Sale_Client on code.RegistrantId equals client.Id
                                      where client.Name == registrantInfo.UserName &&
                                              (reg.DISKSerialNo == terminalInfo.DISKSerialNo ||
                                                  reg.MACSerialNo == terminalInfo.MACSerialNo ||
                                                  reg.MBSerialNo == terminalInfo.MBSerialNo)
                                      select reg).FirstOrDefault();

            return codeReg != null ? true : false;


        }
    }
}